﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Net;
using System.Net.Http;
using System.IO;
using System.Web.Http;
using ExpenseSystem.Core;
using ExpenseSystem.Core.Authority;
using ExpenseSystem.Core.Converter;
using ExpenseSystem.Core.TitleModules;
using ExpenseSystem.Fether;
using ExpenseSystem.Common;
using ExpenseSystem.Lor;
using ExpenseSystem.Model;
using ExpenseSystem.Common.BaseModel;


namespace ExpenseSystem.Controllers
{
    [RoutePrefix("api/Title")]
    public class TitleController : ApiController
    {
        SetInhibition setInhibition;
        GetInhibition getInhibition;
        SetInhibitionMaker inhibitionMaker = new StateInhibitionMaker();
        GetInhibitionMaker getInhibitionMaker = new GetInhibitionMaker();
        UserProfile userProfile;
        public TitleController()
        {
            setInhibition = inhibitionMaker.Make();
            getInhibition = getInhibitionMaker.Make();
            userProfile = Authority.GetUserProfile();
        }
        TitleFetcher fetcher = new TitleFetcher();
        TitleManager manager = TitleManager.CreateInstance();

        [Route("List")]
        [HttpGet]
        public ResponseModel List([FromUri]RequestArgs paramModels)
        {
            return NormalControllerHelper.List(fetcher, "ORG_TITLE_LIST", paramModels, getInhibition);
        }
        [Route("Get")]
        [HttpGet]
        public ResponseModel Get(long id)
        {
            return NormalControllerHelper.Get(fetcher, "ORG_TITLE_LIST", id, getInhibition);
        }

        [Route("Set")]
        [HttpPost]
        public ResponseModel Set(TitleModel data)
        {
            return NormalControllerHelper.Set(fetcher, "ORG_TITLE_SET", data, manager, setInhibition, getInhibition);
        }

        [Route("Remove")]
        [HttpPost]
        public ResponseModel Remove(TitleModel data)
        {
            return NormalControllerHelper.Remove("ORG_TITLE_DEL", data, manager);
        }

        [Route("RemoveById")]
        [HttpGet]
        public ResponseModel RemoveById([FromUri]long[] id)
        {
            return NormalControllerHelper.RemoveById("ORG_TITLE_DEL", id, manager);
        }
    }
}
